Skip to content

feat: Implement multi-registry support with separate feature modules#131

Merged
finxo merged 20 commits into
masterfrom
feat/multi_registry
Jun 17, 2026
Merged

feat: Implement multi-registry support with separate feature modules#131
finxo merged 20 commits into
masterfrom
feat/multi_registry

Conversation

@finxo

@finxo finxo commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

PR's key points

  • Introduces multi-registry support allowing separate feature modules to generate their own registries
  • Adds MiniRegistry interface and refactors Mini class to support multiple registries discovery
  • Creates two sample feature modules (sample-counter-feature and sample-message-feature) demonstrating isolated registries
  • Updates documentation with comprehensive multi-module setup guide and bootstrap patterns
  • Adds MultiRegistrySampleActivity to showcase runtime linking of separate feature registries
  • Maintains backward compatibility with legacy single registry approach

How to review this PR?

  1. Start with the documentation updates in README.md to understand the multi-registry concept
  2. Review the new MiniRegistry interface and Mini.link() implementation
  3. Examine the sample feature modules and how they generate separate registries
  4. Test the MultiRegistrySampleActivity in the sample app to see the feature in action
  5. Verify integration tests pass: ./gradlew :mini-processor-multiregistry-test:test

Related Issues (delete if this does not apply)

Definition of Done

  • Tests pass
  • Works with Proguard
  • There is no outcommented or debug code left

@adriangl adriangl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the effort with the PR :). However, I have a very big concern I'd like to discuss: consumer coupling.

The current implementation is built under an assumption: the project's main module imports and configures Mini and modules provide extra stores or actions for the main Mini to link. While this approach may make sense in a multi-module project, if we bundle Mini inside a library, it would require that any module consuming it must:

  1. Be aware that Mini is being used in the library
  2. Know about and explicitly instantiate the library's Store classes in the module
  3. Pass those stores to Mini.link()

This means that if a library uses Mini internally, its consumers are forced to depend on Mini too. That breaks a fundamental principle of library design: implementation details must stay internal. A consumer of a library should just call its public API, not know or care that it uses Mini under the hood.

We have to rethink this approach before we can merge this. The main blocker that currently disallows using it with multiple modules is that we currently create a unique Mini_Generated per project, no matter the modules or libraries that it contains, and that single instance is used by the Mini code to glue everything together. In the multi-module scenario, or lib + consumer that also uses Mini the build doesn't know which Mini_Generated prevails in compilation time and breaks. We should study how to create multiple instances so each module bundles its own Mini and we don't leak it so consumers don't need to implement it to use the module or lib.

One option that comes to my mind is to generate a MiniComponent or something like that that only belongs to the module where Mini is imported, and use that class to link everything inside the module. That way we wouldn't have any issues regarding multi-module conflicts and it would keep the Mini usage as implementation detail of the module or lib, so consumers don't need to implement Mini themselves. We may keep the concept of registries to do this too.

Comment thread gradle/libs.versions.toml Outdated
Comment thread app/src/main/kotlin/mini/android/sample/MultiRegistrySampleActivity.kt Outdated
Comment thread mini-processor/src/main/java/mini/processor/common/ContainerBuilders.kt Outdated
Comment thread sample-counter-feature/build.gradle.kts Outdated
Comment thread README.md Outdated
Comment thread app/src/main/kotlin/mini/android/sample/MultiRegistrySampleActivity.kt Outdated
Comment thread README.md Outdated
@finxo

finxo commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the effort with the PR :). However, I have a very big concern I'd like to discuss: consumer coupling.

The current implementation is built under an assumption: the project's main module imports and configures Mini and modules provide extra stores or actions for the main Mini to link. While this approach may make sense in a multi-module project, if we bundle Mini inside a library, it would require that any module consuming it must:

1. Be aware that Mini is being used in the library

2. Know about and explicitly instantiate the library's `Store` classes in the module

3. Pass those stores to `Mini.link()`

This means that if a library uses Mini internally, its consumers are forced to depend on Mini too. That breaks a fundamental principle of library design: implementation details must stay internal. A consumer of a library should just call its public API, not know or care that it uses Mini under the hood.

We have to rethink this approach before we can merge this. The main blocker that currently disallows using it with multiple modules is that we currently create a unique Mini_Generated per project, no matter the modules or libraries that it contains, and that single instance is used by the Mini code to glue everything together. In the multi-module scenario, or lib + consumer that also uses Mini the build doesn't know which Mini_Generated prevails in compilation time and breaks. We should study how to create multiple instances so each module bundles its own Mini and we don't leak it so consumers don't need to implement it to use the module or lib.

One option that comes to my mind is to generate a MiniComponent or something like that that only belongs to the module where Mini is imported, and use that class to link everything inside the module. That way we wouldn't have any issues regarding multi-module conflicts and it would keep the Mini usage as implementation detail of the module or lib, so consumers don't need to implement Mini themselves. We may keep the concept of registries to do this too.

What I have implemented now is a module-local Mini runtime model:

  • each module generates its own local MiniRegistry
  • generated registries are unique per module, so there are no class collisions
  • Mini no longer does global discovery or cross-module composition
  • each module links its own reducers explicitly with its own generated registry
  • a library can keep Mini fully internal to the module and expose only its public API
  • consumers no longer need to know Mini exists, instantiate the module’s stores, or call Mini.link() for that module
    In practice, the generated registry now belongs to the module that owns the Mini wiring, and Mini is no longer treated as a single project-wide glue point. We also validated this in two ways:
  • an in-repo module sample for the internal-module case
  • an external consumer sample under samples/isolated-consumer for the library/consumer case
    So the new model is much closer to the “MiniComponent per module” direction you suggested, while keeping MiniRegistry as the local bootstrap abstraction.

@finxo finxo requested a review from adriangl June 8, 2026 10:40
Comment thread mini-processor/src/main/java/mini/processor/common/ContainerBuilders.kt Outdated
@finxo finxo requested a review from adriangl June 15, 2026 09:02
Comment thread mini-common/src/main/java/mini/Mini.kt Outdated
Comment thread mini-processor/src/main/java/mini/processor/kapt/Processor.kt
finxo added 2 commits June 15, 2026 12:29
By: nicolasmertanen
By: nicolasmertanen
Comment thread mini-processor/src/main/java/mini/processor/common/ContainerBuilders.kt Outdated
@DaniAguion DaniAguion self-requested a review June 15, 2026 11:03
@finxo finxo requested a review from DaniAguion June 15, 2026 11:55
Comment thread README.md Outdated
Comment thread README.md Outdated
Comment thread mini-processor/src/main/java/mini/processor/common/ContainerBuilders.kt Outdated
Comment thread mini-processor/src/main/java/mini/processor/kapt/Processor.kt
finxo added 3 commits June 16, 2026 12:29
By: adriangl
By: adriangl
@finxo finxo merged commit 984abfb into master Jun 17, 2026
@finxo finxo deleted the feat/multi_registry branch June 17, 2026 07:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants